Skip Headers

Oracle® OLAP DML Reference 10g Release 2 (10.2) Part Number B14346-01 |
Home | Book List | Contents | Index | Master Index | Feedback

Previous | Next
| View PDF

# FILEERROR

The FILEERROR function returns information about the first error that occurred when you are processing a record from an input file with the data reading statements FILEREAD and FILEVIEW. It can tell you what type of error occurred and where Oracle OLAP was in the record. The keyword you specify as an argument determines the kind of information that is returned.

You should call FILEERROR once to find out the type of error. Then, you can call FILEERROR again to get more details about what caused the error. The return values for the type of error are also FILEERROR keywords. When FILEERROR returns a value other than `NA`, then you would probably call FILEERROR a second time using the return value itself as an argument.

The abbreviation for FILEERROR is FILEERR

Return Value

Varies depending on the specified keyword.

Syntax

FILEERROR (TYPE|POSITION|WIDTH|VALUE|DIMENSION)

Arguments

TYPE

  Returns a text expression that specifies the type of error that has occurred. The types of errors and their meanings are listed in Table 12-3, "Types of Errors Returned by FILEERROR".

  Table 12-3 Types of Errors Returned by FILEERROR

  Return Value | Meaning
  --- | ---
  DIMENSION | The data reading statements tried to set the status of a dimension (through an implicit or explicit MATCH attribute), but the specified position or value did not exist.
  NA | No error occurred in the processing of the current record.
  POSITION | The data reading program tried to read from an invalid location in the record. A POSITION error can occur when the field or column is before the beginning of the record or when the field extends past the end of the record. An error beyond the end of the record occurs only for binary or packed data; for symbolic (textual) data, the data reading statements pad short records with blanks.
  VALUE | The value could not be converted to the requested data type. For packed data, this means the record had an invalid hexadecimal digit.
  WIDTH | The data reading statements specified an invalid field width. Invalid widths depend on the format of the data, which can be symbolic, packed, or binary: For symbolic format, the width is invalid when it is less than 1 or when it is `NA`. Note that `NA` is acceptable for ID data. For packed format, the width is invalid when it is less than 1, greater than 8, or `NA`. For binary format, the width requirement depends on whether the data is `INTEGER` or `DECIMAL` (floating-point). Integer data must have a width of 1, 2, or 4. Decimal data must have a width of 4 or 8.

POSITION

  Returns an INTEGER that is the column number (for RULED records) or field number (for STRUCTURED records) when the error occurred.

WIDTH

  Returns an INTEGER that is the current field width. It will return `NA` when `NA` was specified as the width or the error was a POSITION error. A POSITION error stops processing before the width can be evaluated.

VALUE

  When the error type is VALUE, it returns a text expression that is the value that could not be converted. When the data is packed, the invalid value is shown as hexadecimal escapes. When the error type is DIMENSION, it returns the value that did not match any existing dimension value. For other error types, it returns `NA`.

DIMENSION

  When the error type was DIMENSION, it returns a text expression that is the name of the dimension that had no matching dimension values. For other error types, it returns `NA`.

Notes

Flow of Control

When an error occurs in FILEREAD or FILEVIEW, processing of the current record stops and Oracle OLAP displays an appropriate error message. Then, when your program has a trap label, control branches to the label where you might call FILEERROR to investigate the problem. When you branch back to a FILEREAD or FILENEXT function, processing continues with the next record. When there are more errors in the record, they will not be evaluated.

Displaying Error Messages in the Current Outfile

Set ECHOPROMPT to `YES` in your data reading program when you want error messages to be displayed in the current outfile. When the error occurred during FILEREAD or FILEVIEW, any evaluation by FILEERROR occurs after the error message.

Examples

Example 12-14 Error-Handling with TRAP

This example shows a sample trap label (ERROR:) and the error-handling code that follows it. (For information on error trapping and trap labels, see the TRAP command.) The code checks whether the file has been opened. If so, it checks whether the error that caused the branch is a data reading error. When it is, the program calls FILEERROR in a SHOW command to display information about the error. The body of the program (not shown) contains code that opens the file and assigns a file unit number to the variable `fil.unit`. ERRTYPE is a local variable that is declared at the beginning of the program.

    error:
    IF fil.unit EQ NA
      THEN DO
        POPLEVEL 'save'
        RETURN
      DOEND
    IF ERRORNAME NE 'attn'
      THEN DO
        ERRTYPE = FILEERROR(TYPE)
        IF ERRTYPE NE NA
          THEN SHOW JOINCHARS('Error in record ' RECNO(fil.unit) -
             ' in column ' FILEERROR(POSITION) ': ' -
             ERRTYPE ' ' FILEERROR(&ERRTYPE))
        TRAP ON ERROR
        GOTO NEXT
      DOEND
    FILECLOSE fil.unit
    POPLEVEL 'save'
    RETURN